<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

	<head>
		<title>Gimme CSS Selector Tests</title>

		<script type = "text/javascript" src = "../jsunit/app/jsUnitCore.js"></script>
		<script type = "text/javascript" src = "../utils/jsunit/jsUnitHelperFunctions.js"></script>
		<script type = "text/javascript" src = "../build/debug/gimme.js"></script>
		
		<script type = "text/javascript">			
			function test_selectIdZoo()
			{
				var gObj = Gimme('#zoo');
				checkArrays(getM('zoo'), gObj.entities());
			}
			
			function test_selectIdForest()
			{
				var gObj = Gimme('#forest');
				checkArrays(getM('forest'), gObj.entities());
			}
			
			function test_classMammal_in_IdForest()
			{
				var gObj = Gimme('#forest .mammal');
				checkArrays(this.getM('chipmunk1', 'gazelle1'), gObj.entities());
			}			
			
			function test_firstChild_of_IdZoo()
			{
				var gObj = Gimme('#zoo *:first-child');
				checkArrays(this.getM('panda1'), gObj.entities());
			}
			
			
			function test_selectByAttributeOnly()
			{
				var gObj = Gimme('*[foo]');
				checkArrays(this.getM('panda3'), gObj.entities());
			}
			
			function test_selectByAttributeValueNoSpaces()
			{
				var gObj = Gimme('*[foo=bar]');
				checkArrays(this.getM('panda3'), gObj.entities());
			}
			
			function test_selectByAttributeValueWithSpaces()
			{
				var gObj = Gimme('*[foo = bar]');
				checkArrays(this.getM('panda3'), gObj.entities());
			}
			
			function test_selectByAttributeValueWithQuotes()
			{
				var gObj = Gimme('*[foo = "bar"]');
				checkArrays(this.getM('panda3'), gObj.entities());
			}
			
			function test_selectAttributeStartsWith()
			{
				var gObj = Gimme('*[foo ^= ba]');
				checkArrays(this.getM('panda3'), gObj.entities(), 'Arrays are not equal');
			}
			
			function test_selectAttributeEndsWith()
			{
				var gObj = Gimme('*[foo $= ar]');
				checkArrays(this.getM('panda3'), gObj.entities());
			}
			
			function test_selectAttributeContains()
			{
				var gObj = Gimme('*[foo *= a]');
				checkArrays(this.getM('panda3'), gObj.entities());
			}
			
			function test_selectPandaAdjacentToPanda()
			{
				var gObj = Gimme('.panda + .panda');
				checkArrays(this.getM('panda3'), gObj.entities());
			}
			
			function test_selectIvyGeneralSiblingOfPineTreeInForest()
			{
				var gObj = Gimme('#forest .pine.tree ~ .ivy');
				checkArrays(this.getM('ivyPlant1'), gObj.entities());
			}
			
		</script>
	</head>

	<body>
		<h1>Gimme Selector Tests</h1>

		<div id = "zoo" class = "place man-made">
			<span id = "panda1" class = "panda">Panda1</span>
			<span id = "tiger1" class = "tiger">Tiger1</span>
			<span id = "panda2" class = "panda">Panda2</span>
			<span id = "panda3" class = "panda" foo = "bar">Panda3</span>
		</div>
		<div id = "forest" class = "place natural">
			<p id = "tree1" class = "tree pine">Pine tree 1</p>
			<p id = "tree2" class = "tree oak">Oak tree 1</p>
			<span id = "chipmunk1" class = "mammal chipmunk">Chipmunk 1</span>
			<span id = "gazelle1" class = "mammal gazelle">Gazelle 1</span>
			<p id = "ivyPlant1" class = "ivy poison">Poison Ivy Plant 1</p>
		</div>
	</body>

</html>